//短信
/**
 * https://swagger.io/specification/
 * @openapi
 * tags:
 * - name: ali_msg
 *   description: 短信服务
 */
const router = require("express-promise-router")();


const AliMsgService = require("../../services/ali_msg");


/**
 * @openapi
 * /teacher/ali_msg/back_report:
 *   post:
 *     tags:
 *     - ali_msg
 *     summary: 退回报告短信通知学生
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               phoneNumber:
 *                 type: string
 *               reportId:
 *                  type: string
 *               boxName:
 *                 type: string
 *               score_item:
 *                  type: string
 *               backReason:
 *                  type: string
 *       required: true
 *     responses:
 *       200:
 *         description: 成功
 */
router.post('/back_report', async function(req, res) {
    const {phoneNumber,reportId,boxName,score_item,backReason}=req.body;
    try{
        const result=await AliMsgService.sendReportBackMsg(phoneNumber,reportId,boxName,score_item,backReason);
        res.send(result)
    }catch (e) {
        res.status(400).send({error:e.toString()}); //失败 400,返回{error:"..."}
    }
});

module.exports = router;